package com.mzj.saas.front;

import com.haixiaoke.saas.repository.core.AjaxResult;
import com.haixiaoke.saas.repository.core.BaseController;
import com.haixiaoke.saas.repository.core.page.TableDataInfo;
import com.haixiaoke.saas.repository.pojo.OpHouse;
import com.haixiaoke.saas.repository.service.IOpHouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

import static com.mzj.saas.front.OpConstant.HOUSE_STATUS_PUBLISHED;

@RestController
@RequestMapping("/front/opHouse")
public class FrontOpHouseController extends BaseController {

    @Autowired
    private IOpHouseService opHouseService;


    /**
     * 查询公众号房源列表
     */
    @GetMapping("/list")
    public TableDataInfo list(OpHouse opHouse) {
        startPage();
        opHouse.setStatus(OpConstant.HOUSE_STATUS_PUBLISHED);
        List<OpHouse> list = opHouseService.selectOpHouseList(opHouse);
        return getDataTable(list);
    }

    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(opHouseService.selectOpHouseById(id));
    }


}
